#!/usr/bin/python
# coding: utf-8
import smtplib
import sys
import time
from email.mime.text import MIMEText

time_1 = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())

mail_host = 'smtp.qq.com'
mail_user = '2247837348@qq.com'
mail_pass = 'mvofmbzhgodwecdg'
#to='1013367229@qq.com'
#subject='你好'
#content='邮件测试'
def send_mail(to_list,subject,content):
    me = '2247837348@qq.com'
    msg = MIMEText(content)
    msg['Subject'] = subject
    msg['From'] = me
    msg['to'] = to_list
    s = smtplib.SMTP_SSL()
    s.connect(mail_host,465)
    s.login(mail_user,mail_pass)
    s.sendmail(me,to_list,msg.as_string())
    s.close()

if __name__ == "__main__":
    send_mail(sys.argv[1],sys.argv[2],sys.argv[3])
    f = open('/tmp/1.txt','a')
    f.write(time_1 + ' ' '发送成功''\n')
    f.close()
else:
    f = open('/tmp/1.txt','a')
    f.write(time_1 + ' ' '发送失败''\n')
    f.close()
